package com.aco.party.web.validator.system;

import com.aco.party.web.command.system.EditPeopleCommand;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Created by flying on 3/10/2016 0010.
 */
public class EditPeopleValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return EditPeopleCommand.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name.empty", "名字不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "eName", "error.eName.empty", "英文名不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "company", "error.company.empty", "公司名称不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "position", "error.position.empty", "职位不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "platform", "error.platform.empty", "平台不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "type", "error.type.empty", "前言不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "area", "error.area.empty", "描述不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "iconUrl", "error.iconUrl.empty", "主图不能为空");

    }
}
